package me.firstapp.manage.topic;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import me.firstapp.common.json.SingleObject;
import me.firstapp.common.module.bbs.JsonReply;
import me.firstapp.manage.common.BaseManage;
import me.firstapp.spi.bbs.ReplyService;

@Controller
@RequestMapping(value = "/replyManagePage")
public class ReplyManagePage extends BaseManage {

	@Autowired
	private ReplyService replyService;

	@RequestMapping(value = "/replyList.html", method = RequestMethod.GET)
	public ModelAndView replyListView(Long topicId, HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		modelMap.put("topicId", topicId);
		return new ModelAndView("reply/replyList", modelMap);
	}

	@RequestMapping(value = "/replyDetail.html", method = RequestMethod.GET)
	public ModelAndView replyDetailView(Long replyId, HttpServletRequest request, HttpServletResponse response,
			ModelMap modelMap) {
		SingleObject<JsonReply> singObject = replyService.findReplyById(replyId);
		modelMap.put("reply", singObject.getObject());
		return new ModelAndView("reply/replyDetail", modelMap);
	}
}
